/*
 * @Author: yangni 920556271@qq.com
 * @Date: 2023-12-19 15:15:48
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-02-28 15:34:34
 * @FilePath: /yt-devops/lib/pages/tasks/finish_report_task/finish_report_task_view.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:throttling/throttling.dart';
import 'package:yt_devops/components/app_bar/app_bar_widget.dart';
import 'package:yt_devops/components/brn/brn_input_text.dart';
import 'package:yt_devops/components/gaps.dart';
import 'package:yt_devops/components/yt_button.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/styles/styles.dart';
import 'package:yt_devops/utils/debounce_utils.dart';
import 'finish_report_task_controller.dart';

class FinishReportTaskPage extends GetView<FinishReportTaskController> {
  const FinishReportTaskPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colour.white,
      appBar: AppBarWidget.defaultAppBar(ResKey.completionReason.tr),
      body: Padding(
        padding: EdgeInsets.fromLTRB(16.w, 20.h, 16.w, 51.w),
        child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
          ...descriptWidget(),
          Expanded(
            child: Align(
              alignment: Alignment.bottomCenter,
              child: GetBuilder<FinishReportTaskController>(
                builder: (controller) => YtButton(
                  enabled: controller.textEditingController.text.isNotEmpty,
                  text: ResKey.confirm.tr,
                  radius: BorderRadius.circular(10.w),
                  size: Size(311.w, 48.8.h),
                  onPress: controller.commit,
                ),
              ),
            ),
          )
        ]),
      ),
    );
  }

  List<Widget> descriptWidget() {
    return [
      Text(
        ResKey.enterCompletionReason.tr,
        style: TextStyle(
            color: Colour.mainTextColor,
            fontSize: 16.sp,
            fontWeight: FontWeight.bold,
            height: 2),
      ),
      Gaps.vGap16,
      YBrnInputText(
          minHeight: 120.h,
          maxLength: 200,
          minLines: 4,
          padding: EdgeInsets.all(16.w),
          textLengthSize: 12.sp,
          textEditingController: controller.textEditingController,
          onTextChange: (input) =>
              DebounceUtils.throttle(() => controller.onChangehandle(input)),
          bgColor: Colour.backgroundColor)
    ];
  }
}
